package com.prs.crm.dao.person.impl;


import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.person.DossierCultivateDao;
import com.prs.crm.domain.person.DossierCultivate;

public class DossierCultivateDaoImpl extends BaseDaoImpl<DossierCultivate> implements DossierCultivateDao{

	@SuppressWarnings("unchecked")
	@Override
	public String getDoscurById() {
		return (String) this.getHibernateTemplate().execute(
			      new HibernateCallback() {   
						public Object doInHibernate(Session session) throws HibernateException {
							Query query =  session.createQuery("select max(id) from Dossier");
							List istStr=query.list();
							if(istStr!=null)
							{						   
							return 	istStr.get(0)+"";
							}
							return "";	
						}   
				 } );
	}
	/**
	 * 根据人员PersonID 获取档案表关联数据
	 */
	public List getDataperson(final String personId) {
		Criteria criteria=this.getSession().createCriteria(DossierCultivate.class);
		return criteria.list();		
	}
}
